using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using InfoTech.Core.Data.Attributes;
using InfoTech.Core.Data.Dataable;
using InfoTech.Core.Data.Persistence;
using InfoTech.Utilities.Generic;

namespace InfoTech.LanTranh.MucVu.Bussiness
{
	[Serializable]
	[ExtraTable(Name = "QUANHUYEN", Schema="dbo")]
	[Table(Name = "[dbo].[QUANHUYEN]")]
	public partial class QUANHUYEN : ObjPersistence, IDeleteable, IUpdateable, IInsertable, ISelectable, IDeleteablebyId, IUpdateablebyId, ISelectablebyId
	{

		#region Fields

		private System.Guid _maquanhuyen;

		private System.Guid? _matinhthanh;

		private System.String _tenquanhuyen;

		private System.Boolean? _isdata;

		private System.Boolean? _isdefault;

		private IEnumerable<HOGIADINH_DIACHI> _ref_hogiadinh_diachi;

		private IEnumerable<XAPHUONG> _ref_xaphuong;

		private IEnumerable<GIAODAN> _ref_giaodan;

		private IEnumerable<GIAODAN_DIACHI> _ref_giaodan_diachi;

		private IEnumerable<HOGIADINH> _ref_hogiadinh;

		private TINHTHANH _prt_tinhthanh;

		#endregion

		#region Properties

		[ExtraColumn(DbType = "uniqueidentifier", Length = 0, TypeName = "System.Guid", Type = typeof(System.Guid), CanBeNull = false)]
		[Column(Name = "MAQUANHUYEN", DbType = "uniqueidentifier", IsPrimaryKey = true, CanBeNull = false)]
		public System.Guid MAQUANHUYEN
		{
			get
			{
				return _maquanhuyen;
			}
			set
			{
				OnChanged(this, "MAQUANHUYEN");
				_maquanhuyen = value;
			}
		}

		[ExtraColumn(DbType = "uniqueidentifier", Length = 0, TypeName = "System.Guid", Type = typeof(System.Guid), CanBeNull = true)]
		[Column(Name = "MATINHTHANH", DbType = "uniqueidentifier", IsPrimaryKey = false, CanBeNull = true)]
		public System.Guid? MATINHTHANH
		{
			get
			{
				return _matinhthanh;
			}
			set
			{
				OnChanged(this, "MATINHTHANH");
				_matinhthanh = value;
			}
		}

		[ExtraColumn(DbType = "nvarchar", Length = 1000, TypeName = "System.String", Type = typeof(System.String), CanBeNull = true)]
		[Column(Name = "TENQUANHUYEN", DbType = "nvarchar(1000)", IsPrimaryKey = false, CanBeNull = true)]
		public System.String TENQUANHUYEN
		{
			get
			{
				return _tenquanhuyen;
			}
			set
			{
				OnChanged(this, "TENQUANHUYEN");
				_tenquanhuyen = value;
			}
		}

		[ExtraColumn(DbType = "bit", Length = 0, TypeName = "System.Boolean", Type = typeof(System.Boolean), CanBeNull = true)]
		[Column(Name = "ISDATA", DbType = "bit", IsPrimaryKey = false, CanBeNull = true)]
		public System.Boolean? ISDATA
		{
			get
			{
				return _isdata;
			}
			set
			{
				OnChanged(this, "ISDATA");
				_isdata = value;
			}
		}

		[ExtraColumn(DbType = "bit", Length = 0, TypeName = "System.Boolean", Type = typeof(System.Boolean), CanBeNull = true)]
		[Column(Name = "ISDEFAULT", DbType = "bit", IsPrimaryKey = false, CanBeNull = true)]
		public System.Boolean? ISDEFAULT
		{
			get
			{
				return _isdefault;
			}
			set
			{
				OnChanged(this, "ISDEFAULT");
				_isdefault = value;
			}
		}

		public IEnumerable<HOGIADINH_DIACHI> REF_HOGIADINH_DIACHI
		{
			get
			{
				if (RefreshType == InfoTech.Core.Data.RefreshType.Allway || (RefreshType == InfoTech.Core.Data.RefreshType.OnlyonNull && _ref_hogiadinh_diachi == null))
					InfoTech.Core.Data.Receiver.TypeObject<HOGIADINH_DIACHI>.Select(this, "REF_HOGIADINH_DIACHI", new[] { new Vector<string, string>("MAQUANHUYEN", "MAQUANHUYEN"), }, InfoTech.Core.Data.RelationType.OnetoMany);
				return _ref_hogiadinh_diachi;
			}
			set
			{
				_ref_hogiadinh_diachi = value;
			}
		}

		public IEnumerable<XAPHUONG> REF_XAPHUONG
		{
			get
			{
				if (RefreshType == InfoTech.Core.Data.RefreshType.Allway || (RefreshType == InfoTech.Core.Data.RefreshType.OnlyonNull && _ref_xaphuong == null))
					InfoTech.Core.Data.Receiver.TypeObject<XAPHUONG>.Select(this, "REF_XAPHUONG", new[] { new Vector<string, string>("MAQUANHUYEN", "MAQUANHUYEN"), }, InfoTech.Core.Data.RelationType.OnetoMany);
				return _ref_xaphuong;
			}
			set
			{
				_ref_xaphuong = value;
			}
		}

		public IEnumerable<GIAODAN> REF_GIAODAN
		{
			get
			{
				if (RefreshType == InfoTech.Core.Data.RefreshType.Allway || (RefreshType == InfoTech.Core.Data.RefreshType.OnlyonNull && _ref_giaodan == null))
					InfoTech.Core.Data.Receiver.TypeObject<GIAODAN>.Select(this, "REF_GIAODAN", new[] { new Vector<string, string>("MAQUANHUYEN", "MAQUANHUYEN"), }, InfoTech.Core.Data.RelationType.OnetoMany);
				return _ref_giaodan;
			}
			set
			{
				_ref_giaodan = value;
			}
		}

		public IEnumerable<GIAODAN_DIACHI> REF_GIAODAN_DIACHI
		{
			get
			{
				if (RefreshType == InfoTech.Core.Data.RefreshType.Allway || (RefreshType == InfoTech.Core.Data.RefreshType.OnlyonNull && _ref_giaodan_diachi == null))
					InfoTech.Core.Data.Receiver.TypeObject<GIAODAN_DIACHI>.Select(this, "REF_GIAODAN_DIACHI", new[] { new Vector<string, string>("MAQUANHUYEN", "MAQUANHUYEN"), }, InfoTech.Core.Data.RelationType.OnetoMany);
				return _ref_giaodan_diachi;
			}
			set
			{
				_ref_giaodan_diachi = value;
			}
		}

		public IEnumerable<HOGIADINH> REF_HOGIADINH
		{
			get
			{
				if (RefreshType == InfoTech.Core.Data.RefreshType.Allway || (RefreshType == InfoTech.Core.Data.RefreshType.OnlyonNull && _ref_hogiadinh == null))
					InfoTech.Core.Data.Receiver.TypeObject<HOGIADINH>.Select(this, "REF_HOGIADINH", new[] { new Vector<string, string>("MAQUANHUYEN", "MAQUANHUYEN"), }, InfoTech.Core.Data.RelationType.OnetoMany);
				return _ref_hogiadinh;
			}
			set
			{
				_ref_hogiadinh = value;
			}
		}

		public TINHTHANH PRT_TINHTHANH
		{
			get
			{
				if (RefreshType == InfoTech.Core.Data.RefreshType.Allway || (RefreshType == InfoTech.Core.Data.RefreshType.OnlyonNull && _prt_tinhthanh == default(TINHTHANH)))
					InfoTech.Core.Data.Receiver.TypeObject<TINHTHANH>.Select(this, "PRT_TINHTHANH", new[] { new Vector<string, string>("MATINHTHANH", "MATINHTHANH"), }, InfoTech.Core.Data.RelationType.OnetoOne);
				return _prt_tinhthanh;
			}
			set
			{
				_prt_tinhthanh = value;
			}
		}

		#endregion

		#region Reflector

		public System.Type Reflector()
		{
			return typeof(QUANHUYEN);
		}
		public object Current
		{
			get { return this; }
		}

		#endregion

	}
}
